<%-- 
    Document   : index
    Created on : 2013-09-18, 09:43:49
    Author     : galbanie
--%>
<% 
    String resultat = "";
    String nombre1 = "";
    String nombre2 = "";
    String addS = "", sousS = "", multS = "", divS = "";
    //out.println(request.getAttribute("resultat"));
    if(request.getAttribute("resultat") != null) resultat = String.valueOf(request.getAttribute("resultat"));
    if(request.getParameter("nb1") != null) nombre1 = String.valueOf(request.getParameter("nb1"));
    if(request.getParameter("nb2") != null) nombre2 = String.valueOf(request.getParameter("nb2"));
    if(request.getAttribute("addSelected") != null)addS = "selected";
    if(request.getAttribute("sousSelected") != null)sousS = "selected";
    if(request.getAttribute("multSelected") != null)multS = "selected";
    if(request.getAttribute("divSelected") != null)divS = "selected";
    
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Labo Collaboration</title>
        <style>
            body{
                background-color: #656565;
                color : #fefefe;
                font-size: 100%;
            }
            h1{text-align: center;}
            form{
                display: block;
                width: 40%;
                margin: 0 auto;
                padding: 20px 40px;
            }
            input{
                height: 30px;
                border: 1px solid #fefefe;
            }
        </style>
    </head>
    <body>
        <% if(session.getAttribute("user") == null){ %>
        <h1>Connection</h1>
        <form method="POST" action="./Controleur">
            <input type="hidden" name="formulaire" value="connexion"/>
            <label>Utilisateur : </label>
            <input type="text" name="user" />
            <label>Mot de passe : </label>
            <input type="password" name="pwd" />
            <input type="submit" value="Connexion"/>
        </form>
        <% }else{%>
        <div>
            <p>Salut <span><%= (String)session.getAttribute("user")%></span> <a href="./Controleur?action=deconnexion">Deconnexion</a></p>
        </div>
        <h1>La fausse calculette</h1>
        <form method="POST" action="./Controleur">
            <input type="text" name="nb1" value="<%=nombre1%>"/>
            <select name="operateur">
                <option value="addition" <%=addS%> >+</option>
                <option value="soustraction" <%=sousS%> >-</option>
                <option value="multiplication" <%=multS%> >*</option>
                <option value="division" <%=divS%> >/</option>
            </select>
            <input type="text" name="nb2" value="<%=nombre2%>"/>
            <span>=</span>
            <input type="text" name="result" value="<%=resultat%>" readonly />
            <input type="submit" value="Calculer"/>
        </form>
        <% } %>
    </body>
</html>
